import { FormSchema } from '/@/components/BasicForm/type/form';

export const detailSchemas: FormSchema[] = [
  {
    field: 'id',
    label: '应用ID',
    required: false,
    component: 'Input',
    show: false,
  },
  {
    field: 'name',
    label: '名称',
    component: 'Input',
    componentProps: {
      placeHolder: '请输入应用名称',
    },
    labelWidth: 100,
    colProps: { span: 12 },
    required: true,
  },
  {
    field: 'nameEn',
    label: '英文名称',
    component: 'Input',
    componentProps: {
      placeHolder: '请输入应用英文名称',
    },
    labelWidth: 100,
    colProps: { span: 12 },
    required: true,
  },
  {
    field: 'architecture',
    label: '架构',
    component: 'Select',
    componentProps: ({ formActionType }) => {
      return {
        placeHolder: '请选择应用架构',
        options: [
          {
            label: '微服务',
            value: '微服务',
          },
          {
            label: '单体',
            value: '单体',
          },
        ],
        onChange: async (e) => {
          const { setFieldsValue, updateSchema } = formActionType;
          setFieldsValue({
            ifIntegrateThirdApp: false,
          });
          if (e === '单体') {
            updateSchema({
              field: 'ifIntegrateThirdApp',
              dynamicDisabled: false,
            });
          } else {
            updateSchema({
              field: 'ifIntegrateThirdApp',
              dynamicDisabled: true,
            });
          }
        },
      };
    },
    labelWidth: 100,
    colProps: { span: 12 },
    required: true,
  },
  {
    field: 'version',
    label: '版本',
    component: 'Input',
    labelWidth: 100,
    componentProps: {
      placeHolder: '请输入应用版本',
    },
    colProps: { span: 12 },
    required: true,
  },
  {
    field: 'description',
    label: '描述',
    component: 'InputTextArea',
    componentProps: {
      placeHolder: '请输入应用描述',
    },
    labelWidth: 100,
    colProps: { span: 24 },
    required: false,
  },
  {
    field: 'idaasAppId',
    label: 'idaas App ID',
    component: 'Input',
    componentProps: {
      placeHolder: '请输入idaas App ID',
    },
    labelWidth: 200,
    colProps: { span: 24 },
    required: true,
  },
  {
    field: 'idaasClientId',
    label: 'idaas Client ID',
    component: 'Input',
    componentProps: {
      placeHolder: '请输入idaas Client ID',
    },
    labelWidth: 200,
    colProps: { span: 24 },
    required: false,
  },
  {
    field: 'idaasClientSecret',
    label: 'idaas Client Secret',
    component: 'InputPassword',
    componentProps: {
      placeHolder: '请输入idaas Client Secret',
      visibilityToggle: false,
    },
    labelWidth: 200,
    colProps: { span: 21 },
    dynamicDisabled: true,
    required: false,
  },
  {
    field: 'editSecret',
    label: '',
    component: 'Input',
    slot: 'edit',
    colProps: { span: 3 },
  },
  {
    field: 'domain',
    label: '域名',
    component: 'Input',
    componentProps: {
      placeHolder: '请输入域名',
    },
    labelWidth: 200,
    colProps: { span: 24 },
    required: true,
  },
  {
    field: 'ifIntegrateThirdApp',
    label: '是否集成第三方应用',
    component: 'Switch',
    labelWidth: 200,
    componentProps: {
      checkedChildren: '是',
      unCheckedChildren: '否',
      checkedValue: true,
      unCheckedValue: false,
      defaultChecked: false,
    },
    colProps: { span: 24 },
    required: true,
  },
  {
    field: 'ifIntegrateCm',
    label: '是否集成云商店/IMC',
    component: 'Switch',
    labelWidth: 200,
    componentProps: () => {
      return {
        checkedChildren: '是',
        unCheckedChildren: '否',
        checkedValue: true,
        unCheckedValue: false,
        defaultChecked: false,
      };
    },
    colProps: { span: 24 },
    required: true,
  },

  {
    field: 'cmAppId',
    label: '云商店应用凭据ID',
    component: 'Input',
    componentProps: {
      placeHolder: '请输入云商店应用凭据ID',
    },
    labelWidth: 200,
    colProps: { span: 24 },
    required: false,
    show: ({ values }) => {
      return values.ifIntegrateCm ? true : false;
    },
  },
  {
    field: 'cmProductId',
    label: '云商店商品ID',
    component: 'Input',
    componentProps: {
      placeHolder: '请输入云商店商品ID',
    },
    labelWidth: 200,
    colProps: { span: 24 },
    required: false,
    show: ({ values }) => {
      return values.ifIntegrateCm ? true : false;
    },
  },
  {
    field: 'prodsysInterfaceAddress',
    label: '生产系统接口地址',
    component: 'Input',
    componentProps: {},
    labelWidth: 200,
    colProps: { span: 24 },
    required: false,
    show: ({ values }) => {
      return values.ifIntegrateCm ? true : false;
    },
  },
];
